package com.xtaller.easy.admin.async;

import com.xtaller.common.kit.IdKit;
import com.xtaller.easy.admin.model.SysLog;
import com.xtaller.easy.admin.service.impl.SysDictService;
import com.xtaller.easy.admin.service.impl.SysLogService;
import com.xtaller.easy.admin.service.impl.SysOrganizationalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;



/**
 * Created by Taller on 2018/5/2
 * 缓存异步处理
 */
@Component
public class CacheSysTask {
    @Autowired private SysDictService sysDictService;
    @Autowired private SysLogService logService;
    @Autowired private SysOrganizationalService organizationalService;

    // 异步处理日志
    @Async("taskExecutor")
    public void cacheLog(SysLog log){
        log.setId(IdKit.getId(110));
        logService.createModel(log);
    }
    // 异步缓存字典
    @Async("taskExecutor")
    public void cacheDict(){
        sysDictService.updateCache();
    }
    // 当角色信息修改时更新相关所有用户的缓存
    @Async("taskExecutor")
    public void refurbishData(){
        organizationalService.refurbishData();
    }

}
